package bTree.LeetCode;

public class 删除有序数组中的重复项 {
    public int removeDuplicates(int[] nums) {
        if (nums.length == 0) {
            return 0;
        }
        if (nums.length == 1) {
            return 1;
        }
        int left = 0, right = 1;
        int n = nums.length;
        int index = 1;
        while (right <= n - 1) {
            if (nums[right] != nums[left]) {
                nums[index++] = nums[right];
                left = right;
                right =right+1;
            }else {
                right+=1;
            }

        }
        return index + 1;
    }
}